Laser
The Laser is like a normal scrap mechanic sensor but instead of ON or OFF, It provides more information which could be useful for things like Robot kinematics (More like Sensor-Enhanced Kinematics)
Advanced users: This uses a ray cast for object detection, But this also means that there is an offset between the raycast's starting point and the object itself. it's small but this could cause issues with your math!
Structures
LaserData
This structure contains data that the laser has received
Fields
directionWorld
[ Vec3 ] The direction vector of the ray castfraction
[ number ] The fraction (0-1) of the distance reached until collision divided by the ray's lengthnormalLocal
[ Vec3 ] The normal vector of the surface that was hit, relative to the target's rotation.normalWorld
[ Vec3 ] The normal vector of the hit surfaceoriginWorld
[ Vec3 ] The starting world position of the raycast.pointLocal
[ Vec3 ] The world position of the point that was hit, relative to the target's position.pointWorld
[ Vec3 ] The world position of the point that was hit.type
[ string ] The physics type of the target that was hit. (See sm.physics.types)valid
[ boolean ] Is true if the ray cast was even valid.
Functions
setDistance
Laser.setDistance( distance )
Sets the distance (In Meters!).
Arguments:
- distance [ number ] The new distance.
getLaserData
Laser.getLaserData()
Gets the data of the laser (Will send a ray cast!).
Returns:
- [ boolean ] Is True if it hit something.
- [ LaserData ] The laser data.
toggleLaser
Laser.toggleLaser()
Toggles the visibility of the laser effect.
isBeamEnabled
Laser.isBeamEnabled()
If the laser beam effect is currently enabled.
Returns:
- [ boolean ] If the laser beam is enabled.
ignoreCurrentBody
Laser.ignoreCurrentBody( bool )
Arguments:
- bool [ boolean ] Whether the body is ignored or not.
If true the laser will ignore the body its placed on.